
import request from './http';

//登录
export const loginto = (data) => {
    return request({
        url: '/api/yeahc/login',
        url: '/api/yeahc/login?loginCode='+data.loginCode+"&password="+data.password,
        method: 'post',
        // data: data
    })
}
// 获取个人信息
export const getUserInfo = (data) => {
    return request({
        url: '/api/yeahc/getUserInfo?userId='+data.userid,
        method: 'post',
        // data: data
    })
}
 
// // 首页
export const getHomePage = (data) => {
    return request({
        url: '/api/yeahc/getHomePage?userId='+data.userid,
        method: 'post',
        // data: data
        headers: {
            'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
        },
    })
}


// 获取未读信息数量
export const getWorkMessageNum = (data) => {
    return request({
        url: '/api/yeahc/getWorkMessageNum?userId='+data.userid+'&selectType='+data.selectType,
        method: 'post',
        // data: data
    })
}

// 首页数据
export const getWorkAssignInfo = (data) => {
    return request({
        url: '/api/yeahc/getWorkAssignInfo?userId='+data.userId+'&selectType='+data.selectType+'&beginDate='+data.beginDate+'&endDate='+data.endDate,
        
        method: 'post',
        // data: data
    })
}
// 10.执行层-项目列表（分页） "targetUserId":"1545330744208384000","projectStatus":"","pageNo":1,"pageSize":10,"beginDate":"","endDate":"","projectName":""
export const getLeaderTaskPage = (data) => {
    return request({
        url: '/api/yeahc/getLeaderTaskPage?targetUserId='+data.targetUserId+'&projectStatus='+data.projectStatus+'&selectType='+data.selectType+
        '&pageNo='+data.pageNo+'&pageSize='+data.pageSize+'&beginDate='+data.beginDate+'&endDate='+data.endDate+'&projectName='+data.projectName,
        method: 'post',
        // data: data
    })
}

// 10.执行层-项目列表（分页） "targetUserId":"1545330744208384000","projectStatus":"","pageNo":1,"pageSize":10,"beginDate":"","endDate":"","projectName":""
export const getExecuteTaskPage = (data) => {
    return request({
        url: '/api/yeahc/getExecuteTaskPage?targetUserId='+data.targetUserId+'&projectStatus='+data.projectStatus+'&selectType='+data.selectType+
        '&pageNo='+data.pageNo+'&pageSize='+data.pageSize+'&beginDate='+data.beginDate+'&endDate='+data.endDate+'&projectName='+data.projectName,
        method: 'post',
        // data: data
    })
}
// 项目详情
export const getProjectDetails = (data) => {
    return request({
        url: '/api/yeahc/getProjectDetails?userId='+data.userId+'&objId='+data.objId,
        method: 'post',
        // data: data
    })
}

//任务详情
export const getWorkAssignDetails = (data) => {
    return request({
        url: '/api/yeahc/getWorkAssignDetails?userId='+data.userId+'&objId='+data.objId,
        method: 'post',
        //  data: data
    })
}
// 指派列表
export const getUserList = (data) => {
    return request({
        url: '/api/yeahc/getUserList?userId='+data.userId+'&name='+data.name,
        method: 'post',
        // data: data
    })
}
// 抄送列表
export const getCcUserList = (data) => {
    return request({
        url: '/api/yeahc/getCcUserList?userId='+data.userId+'&name='+data.name,
        method: 'post',
        // data: data
    })
}
// ?userId='+data.userId+'&file'+data.file
export const saveFileUpload = (data) => {
    return request({
        url: '/api/yeahc/saveFileUpload',
        headers:{
            'Content-type': 'multipart/form-data'
          },
        method: 'post',
        data: data
    })
}
// // 更新项目
// export const updateProject = (data) => {
//     return request({
//         url: '/api/yeahc/publishProject',
//         method: 'post',
//         // dataType: "jsonp",
//         // text/plain
//         headers:{
//             'Content-Type':'application/json',  //如果写成contentType会报错
//         //    "Access-Control-Allow-Origin":"*"
//         },
//         // data: JSON.stringify(data)
//         data: data
//     })
// }


// 消息列表
export const getWorkMessagePage = (data) => {
    
    // console.log("data",data)
    return request({
        url: '/api/yeahc/getWorkMessagePage?receiveUserId=' + data.receiveUserId+'&readFlag='+data.readFlag+
        '&pageNo='+data.pageNo+'&pageSize='+data.pageSize+'&projectName='+data.projectName,
        method: 'post',
        // data: data
    })
}

// 信息详情
export const getWorkMessageDetails = (data) => {
    return request({
        url: '/api/yeahc/getWorkMessageDetails?userId=' + data.userId + '&workMessageId=' + data.workMessageId,
        method: 'post',
        // data: data
    })
}

// 领取任务
export const receiveTask = (data) => {
    return request({
        url: '/api/yeahc/receiveTask?userId='+data.userId+'&taskId='+data.taskId+'&workMessageId'+data.workMessageId+'&token='+data.token,
        method: 'post',
        // data: data
    })
}

// 回退任务
export const refuseTask = (data) => {
    return request({
        url: '/api/yeahc/refuseTask?userId='+data.userId+'&taskId='+data.taskId+'&workMessageId'+data.workMessageId+
        '&token='+data.token+'&refuseReason='+data.refuseReason,
        method: 'post',
        // data: data
    })
}

// 提交任务
export const submitTask = (data) => {
    return request({
        url: '/api/yeahc/submitTask?userId=' + data.userId+'&taskId=' + data.taskId+'&finishDescribe=' + 
        data.finishDescribe+'&finishFiles=' + data.finishFiles+'&finishFilesNames=' + data.finishFilesNames+'&token='+data.token,
        method: 'post',
        // data: data
    })
}

// 驳回
export const rejectTask = (data) => {
    return request({
        url: '/api/yeahc/rejectTask?userId=' + data.userId+'&taskId=' + data.taskId+'&workMessageId=' + 
        data.workMessageId+'&refuseReason=' + data.refuseReason+'&endDate=' + data.endDate+'&token='+data.token,
        method: 'post',
        // data: data
    })
}

// 通过
export const adoptTask = (data) => {
    return request({
        url: '/api/yeahc/adoptTask?userId=' + data.userId+'&taskId=' + data.taskId+'&workMessageId=' + 
        data.workMessageId+'&token='+data.token,
        method: 'post',
        // data: data
    })
}

// 案例列表（分页）

// token:tokens.value,
//                   userId:localStorage.getItem('userinfoId'),
//                   projectName:bjdata.projectName,
//                   projectEndDate:bjdata.projectEndDate,
//                   ccUserIds:officeLists,
//                   projectDescribe:bjdata.projectDescribe,
//                   projectFiles:'',
//                   projectFilesNames:'',
//                   workAssignList:JSON.stringify(bjdata.workAssignList)
export const createProject = (data) => {
    console.log('apidata','token='+data.token+'&userId='+data.userId+
    '&projectName='+data.projectName+'&projectEndDate='+data.projectEndDate+'&ccUserIds='+data.ccUserIds+
    '&projectDescribe='+data.projectDescribe+'&projectFiles='+data.projectFiles+
    '&projectFilesNames='+data.projectFilesNames+'&workAssignList='+data.workAssignList,)
    return request({
        // headers:{
        //         'content-type':'application/x-www-form-urlencoded',  //如果写成contentType会报错
        //     //         //    "Access-Control-Allow-Origin":"*"
        //             },
        url: '/api/yeahc/createProject?token='+data.token+'&userId='+data.userId+
        '&projectName='+data.projectName+'&projectEndDate='+data.projectEndDate+'&ccUserIds='+data.ccUserIds+
        '&projectDescribe='+data.projectDescribe+'&projectFiles='+data.projectFiles+
        '&projectFilesNames='+data.projectFilesNames+'&workAssignList='+data.workAssignList,
        // url: '/api/yeahc/createProject',
        //   contentType: 'application/json;charset=utf-8', // 发送的数据类型
        // dataType: 'json',
        method: 'post',
        // data: data
    })
}

export const replaceProject= (data) => {
    return request({
        url: '/api/yeahc/replaceProject?token='+data.token+'&userId='+data.userId+'&id='+data.id+
        '&projectName='+data.projectName+'&projectEndDate='+data.projectEndDate+'&ccUserIds='+data.ccUserIds+
        '&projectDescribe='+data.projectDescribe+'&projectFiles='+data.projectFiles+
        '&projectFilesNames='+data.projectFilesNames+'&workAssignList='+data.workAssignList,
        method: 'post',
        //  data: data
    })
}


//更新个人资料
export const updateUserInfo = (data) => {
    return request({
        url: '/api/yeahc/updateUserInfo?userId='+data.userId+'&wxNickName='+data.wxNickName+'&department='+data.department+'&position='+data.position,
        method: 'post',
        //  data: data
    })
}
// export const getProjectCaseDetails = (data) => {
//     return request({
//         url: '/webapi/yeahc/getProjectCaseDetails?caseId='+data.caseId,
//         method: 'post',
//          data: data
//     })
// }

